feat(mod_config): Allow for nested config values for mods #407
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Goal
The goal of this PR is to allow for mods
config.lua
file to make use of nested values.The Problem
Consider the following:
For sake of example, lets say I have the following as my
config.lua
file for my mod:Lets say the player uses the mod config menu to edit the settings of the mod to make the following table be our current saved config for the mod:
As of right now all is fine, however, lets say the mod developer wants to add a feature to their mod and needs to add a new item in
foo_group_2
, making the newconfig.lua
file look like so:The problem now happens if our player loads the new version of the mod with their old saved config on file, the
SMODS.load_mod_config
method will do a combination of the saved and default configs without taking into account any nesting, resulting in a loaded mod config of a table like this:This is now a problem because the player's game will crash when trying to access
config.foo_group_2.green
The Proposed Solution
With this PR, the final combined table will instead look like this: